import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export const KEY = {
    token: 'ehr-login-token'
}


export default new Vuex.Store({
    state: {
        employeeInfo: {
            empId: "",
            empStatus: 0,
            employeeInfo: null,
            headImage: "",
            highDegree: "",
            id: 0,
            idCardNumber: "",
            job: null,
            jobId: 0,
            major: null,
            name: "",
            status: 0,
            type: null,
            typeId: 0,
        }
    },
    mutations: {
        saveEmployeeInfo(state, empInfo) {
            // 改变状态
            state.employeeInfo = empInfo
        }
    },
    actions: {
        saveLogin(context, loginInfo) {
            // 提交让mutation进行状态改变
            context.commit('saveEmployeeInfo', loginInfo.employee)
            localStorage.setItem(KEY.token,loginInfo.token);
        }
    },
    modules: {}
})
